<?php

namespace Single\Logic;

use School\PBClass;
use School\PBStudenInfoRsp;
use School\PBStudent;
use School\PBStudentDegree;
use School\PBStudentInfoReq;
use School\PBStudentListReq;
use School\PBStudentListRsp;
use School\PBUser;

class StudentInfo extends Base
{
    public $studentId;

    /**
     * StudentList constructor.
     * @param PBStudentInfoReq $req
     */
    public function __construct(PBStudentInfoReq $req)
    {
        $this->studentId = $req->getStudentId();
    }

    public function run(): \Google\Protobuf\Internal\Message
    {
        $id = $this->studentId;
        $i = mt_rand(1, 10);
        $Student = (new PBStudent())->setStudentId(1)
            ->setClass(
                (new PBClass([
                    'classId' => $i, 'name' => $id . 'name'
                ]))
            )
            ->setUser(
                (new PBUser([
                    'user_id' => $id, 'name' => $id . 'name' . $id, 'mobile' => time() + $id
                ]))
            )
            ->setDegree(PBStudentDegree::MIDDLE);

        $rsp = new PBStudenInfoRsp();
        $rsp->setInfo($Student);
        return $rsp;
    }
}
